import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'

import RootPage from '../view/index/RootPage.vue'
import DeskTop from '../view/index/DeskTop.vue'

import Tool from '../global'

import JobManager from '../view/admin/job/JobManager.vue'
import DbsetManager from '../view/admin/dbset/DbsetManager.vue'
import LogManager from '../view/admin/Log/LogManager.vue'
import DictionaryComparison from '../view/admin/dict/DictionaryComparison.vue'
import DictManager from '../view/admin/dict/DictManager.vue'
// 假设这两个组件存在，若不存在需要创建
import LocalDictDownload from '../view/admin/dict/LocalDictDownload.vue'
import PlatformDictDownload from '../view/admin/dict/PlatformDictDownload.vue'

// 定义空布局组件
const EmptyLayout = {
  template: '<router-view />'
}

// 明确指定路由类型为RouteRecordRaw数组
const routes: RouteRecordRaw[] = [
  {
    path: "/",
    component: RootPage,
    redirect: "/job",
    children: [
      { name: "任务信息", path: "/job", component: JobManager },
      { name: "数据库连接信息", path: "/dbset", component: DbsetManager },
      { name: "日志查询", path: "/log", component: LogManager },
      // 字典管理一级目录
      {
        name: "字典管理",
        path: "/dict",
        component: EmptyLayout,
        children: [
          { name: "本地字典下载", path: "local-download", component: DictionaryComparison },
          { name: "平台字典下载", path: "platform-download", component: DictionaryComparison },
          { name: "字典对照", path: "comparison", component: DictionaryComparison }
        ]
      }
    ]
  }
  // { path: "/login", component: LoginPage }
]

const toolObj = new Tool()

const router = createRouter({
  history: createWebHistory(),
  routes  // 现在routes符合RouterOptions的类型要求
})

export default router;
